﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

namespace HRdex_Final.Announcement
{
    public partial class Announcement : System.Web.UI.MasterPage
    {
        string SessionID()
        {
            if (Session["EmployeeID"].ToString() == null)
            {
                Server.Transfer("~/Default.aspx");
                return null;
            }
            else
            {
                return Session["EmployeeID"].ToString();
            }
            
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                    SqlConnection conn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\HRdexDB.mdf;Integrated Security=True;User Instance=True");
                    SqlCommand cmdAdmin = new SqlCommand("SELECT formEmployees.EmployeeID, catUserLevel.catUserLevelName AS [User Level], catPositions.catPositionsName AS Position, catDepartment.DepartmentName AS Department, catCollege.CollegeName AS Office FROM formEmployees INNER JOIN catDepartment ON formEmployees.DeptID = catDepartment.DeptID INNER JOIN catCollege ON formEmployees.CollegeID = catCollege.CollegeID INNER JOIN catPositions ON formEmployees.catPositionsID = catPositions.catPositionsID INNER JOIN catUserLevel ON formEmployees.UserLevelID = catUserLevel.UserLevelID WHERE formEmployees.EmployeeID = " + SessionID(), conn);
                    SqlDataAdapter daAdmin = new SqlDataAdapter(cmdAdmin);
                    DataTable dtAdmin = new DataTable("dtAdmin");
                    daAdmin.Fill(dtAdmin);

                    if (dtAdmin.Rows[0].ItemArray[1].ToString() == "Employee" || dtAdmin.Rows[0].ItemArray[1].ToString() == "Faculty")
                    {
                        Menu1.Visible = false;
                    }
                    else
                    {
                        Menu1.Visible = true;
                    }
            }
            catch (Exception)
            {
                
                
            }

            
        }
    }
}